<template>
	<view>
		<view class="map">
			<map style="width: 100%; height: 750rpx;" location>
			</map>
		</view>
		<!-- <view class="back">
			<uni-icons class="icons" type="arrowleft" ></uni-icons>
		</view> -->
		<!-- 定位图标  起点-->
		<view class="origin">
			<image src="../../../static/img/maintainOver/origin.png" mode=""></image>
			<view class="origin-word">
				起
			</view>
		</view>
		<!-- 定位图标  终点-->
		<view class="terminus">
			<image src="../../../static/img/maintainOver/terminus.png" mode=""></image>
			<view class="origin-word">
				终
			</view>
		</view>
		<!-- 头像信息 -->
		<uni-card>
			<view class="" v-for="(item,index) in maindata" :key="item.id">
				<view class="main">
					<image :src="item.img" mode=""></image>
					<view class="main-time">
						{{item.mainTime}}
						<text>{{item.state}}</text> 
					</view>
				</view>
				<view class="">
					<view class="content">
						{{item.content}}
						<view class="alarm">
							<image :src="item.icon" mode=""></image>
							<text>{{item.startTime}}</text>
						</view>
					</view>
					<view class="address">
						{{item.address}}
					</view>
				</view>
			</view>
		</uni-card>
		
		<!-- 提交人 签名信息 -->
		<uni-card >
			<view class="card" v-for="(item,index) in signaturedata" :key="item.id">
				
				<view class="signature" >
					<view class="successRight">
						<view class="x-m-con">
							<canvas class="mycanvas" canvas-id="mycanvas" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend"></canvas>
						</view>
						<view class="success" v-show="flag== true">
							<image src="../../../static/img/icon_confirmcomplete.png" mode=""></image>
							<text >通过</text>
						</view>
					</view>
					
					<view class="submitOrder">
						<text>提交人:{{item.name}}</text>
						<text>{{item.time}}</text>
					</view>
				</view>
			</view>
		</uni-card>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				maindata:[
					{
						id:0,
						img:"../../../static/logo.png",
						mainTime:"2020-01-15 15:33:23 ",
						state:"开始保养",
						content:"半月保养",
						icon:"../../../static/img/maintainOver/timepiece.png",
						startTime:"1小时22分钟",
						address:"枫林绿洲-1号楼-1单元-南梯"
					}
				],
				flag:true,
				signaturedata:[
					{
						name:"刘德华",
						time:"2020-01-15 15:33:23",
						
					},
					{
						name:"刘德华",
						time:"2020-01-15 15:33:23",
						
					},
				],
				// 画布
				// 画布
				ctx:'',         //绘图图像
				points:[]       //路径点集合 
			}
		},
		// 画布
		onLoad() {
			this.ctx = uni.createCanvasContext("mycanvas",this);   //创建绘图对象
			
			//设置画笔样式
			this.ctx.lineWidth = 4;
			this.ctx.lineCap = "round"
			this.ctx.lineJoin = "round"
		},
		methods: {
			//触摸开始，获取到起点
			touchstart:function(e){
				let startX = e.changedTouches[0].x;
				let startY = e.changedTouches[0].y;
				let startPoint = {X:startX,Y:startY};
				this.points.push(startPoint);
				//每次触摸开始，开启新的路径
				this.ctx.beginPath();
			},
			
			//触摸移动，获取到路径点
			touchmove:function(e){
				let moveX = e.changedTouches[0].x;
				let moveY = e.changedTouches[0].y;
				let movePoint = {X:moveX,Y:moveY};
				this.points.push(movePoint);       //存点
				let len = this.points.length;
				if(len>=2){
					this.draw();                   //绘制路径
				}
				
			},
			
			// 触摸结束，将未绘制的点清空防止对后续路径产生干扰
			touchend:function(){                   
				this.points=[];
			},
			
			/* ***********************************************
			#   绘制笔迹
			#	1.为保证笔迹实时显示，必须在移动的同时绘制笔迹
			#	2.为保证笔迹连续，每次从路径集合中区两个点作为起点（moveTo）和终点(lineTo)
			#	3.将上一次的终点作为下一次绘制的起点（即清除第一个点）
			************************************************ */
			draw: function() {
				let point1 = this.points[0]
				let point2 = this.points[1]
				this.points.shift()
				this.ctx.moveTo(point1.X, point1.Y)
				this.ctx.lineTo(point2.X, point2.Y)
				this.ctx.stroke()
				this.ctx.draw(true)
			},
		}
	}
</script>

<style scoped>
	.uni-card{
		width: 670rpx;
		/* height: 220rpx; */
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05);
		border: none;
		border-radius: 16rpx;
		margin: 0 auto;
		margin-top: 20rpx;
	}
	/* 返回图标 */
	.back{
		position: fixed;
		top:119rpx;
		left: 40rpx;
	}
/* 	.icons{
		transform: scale(0.7,0.7)
	} */
	/* 定位图标 起点*/
	.origin{
		position: fixed;
		top:207rpx;
		left: 208rpx;
	}
	.origin image{
		vertical-align: middle;
		width: 64rpx;
		height: 82rpx;
	}
	.origin-word{
		position: absolute;
		top:1rpx;
		left: 14rpx;
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
	}
	/* 终点 */
	.terminus{
		position: fixed;
		top:474rpx;
		right: 167rpx;
	}
	.terminus image{
		vertical-align: middle;
		width: 64rpx;
		height: 82rpx;
	}
	/* 内容区域 */
	.main{
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		border-bottom: 1rpx solid #E2E6EF;
		padding-bottom: 15rpx;
	}
	.main image{
		width: 80rpx;
		height: 80rpx;
		background: #E2E6EF;
		border: 4rpx solid #F0F3F6;
		border-radius: 50%;
		margin-right: 18rpx;

	}
	.main-time{
		font-size: 24rpx;
		color: #34363D;
	}
	.main-time text{
		margin-left: 20rpx;
	}
	/* 头像下面内容 */
	.content{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin-top: 20rpx;
		font-size: 30rpx;
		font-weight: 400;
		color: #34363D;
	}
	.alarm image{
		width: 24rpx;
		height: 24rpx;
		vertical-align: middle;
		margin-right: 10rpx;
	}
	.alarm text{
		font-size: 24rpx;
		color: #34363D;

	}
	.address{
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #989BA6;
	}
	
	/* 提交人 */
	/* 画布 */
	/* .signature{
		margin-top: 20rpx;
	} */
	.mycanvas{
		/* width: 100%; */
		width: 300rpx;
		height: 151rpx;
		/* height: calc(100vh - 1200upx); */
		background-color: #ECECEC;
	}
	.x-m-con{
		width: 255rpx;
		/* height: 151rpx; */
		margin: 0 auto;
	}
	
	.success{
		width: 150rpx;
		height: 56rpx;
		background: #017EFE;
		box-shadow: 0px 5px 10px 0px rgba(1, 126, 254, 0.2);
		border-radius: 28px;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.success image{
		width: 24rpx;
		height: 24rpx;
		margin-right: 15rpx;
	}
	.success text{
		color: #FFFFFF;
	}
	.successRight{
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
	}
	.submitOrder{
		padding: 0 20rpx;	
		word-spacing: 10rpx;
		
	}
	.submitOrder text{
		margin: 0 10rpx;
	}
	
</style>
